import requests
from lxml import etree

headers = {
    "user-agent":"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36",
    "cookie":"JSESSIONID=C457B14CDF585AD04E021AE5471A614B; SWSPT=JgHgYSUuwTAe8t9NHuTqZvCGEWaiym39Pr5VqirQlVhCe7DLQqenWUnVPXNMf4UAbXs8+hVdAoAnom63r/59iGoBkhB9ZWjvh9PsCPBt0w4=; zh_choose_1=s; arialoadData=true; ariawapChangeViewPort=true; ariauseGraymode=false",
    "referer":"https://www.pingxiang.gov.cn/col/col15/index.html?uid=127&pageNum=9"
}
params = {
    "startrecord": 1,
    "endrecord": 45,
    "perpage": 15,
    "col": 1,
    "webid": 1,
    "path": "http://www.pingxiang.gov.cn/",
    "columnid": 15,
    "sourceContentType": 1,
    "unitid": 127,
    "webname": "萍乡市人民政府",
    "permissiontype": 0
}
res = requests.post("https://www.pingxiang.gov.cn/module/web/jpage/dataproxy.jsp?startrecord=1&endrecord=45&perpage=15",headers=headers,params=params)

xml_root = etree.fromstring(res.text)
recodes = xml_root.xpath("//record/text()")
for recode in recodes:
    html_content = recode.strip()
    html_root = etree.HTML(html_content)
    a_tags = html_root.xpath('//a')
    for a in a_tags:
        href = a.get('href')
        title = a.get('title')
        response = requests.get(href)
        print(title)
        print(response.text.encode())

